<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<script type="text/javascript">
//name space for this page
var p00_cust_modify = {
    mid : "${menuId}",
    focusId : "p00_cust_modify_mobile"
};

// Auto fill Addr
p00_cust_modify.autoFillAddr = function() {
    var t1 = Ext.getCmp("p00_cust_modify_svc_locate_id").getRawValue();
    var t2 = Ext.getCmp("p00_cust_modify_park_space").getValue();
    Ext.getCmp("p00_cust_modify_addr").setValue(t1 + " " + t2);
};

// add Panel
p00_cust_modify.addPanel = Ext.create("Ext.form.Panel", {
    region : "center",
    buttonAlign : "left",
    frame : true,
    bodyPadding : 5,
    defaults : {
        xtype : "fieldset",
        layout : "anchor",
        defaults : {
            anchor : "100%",
            layout : "hbox",
            defaultType : "textfield",
            padding : "2 0",
            defaults : {
                labelAlign : "left",
                labelWidth : 120,
                width : 280,
                labelStyle : "padding-left: 15px"
            }
        }
    },
    items : [ {
        title : "基本信息",
        items : [{
            xtype : "container",
            items : [ {
                xtype : "hiddenfield",
                name : "cust_id",
                value : "${cust_id}"
            } ]
        }, {
            xtype : "container",
            items : [ {
                id : "p00_cust_modify_mobile",
                fieldLabel : "手机号码",
                name : "mobile",
                value: "${mobile}",
                allowBlank : false
            }, {
                fieldLabel : "车牌号码",
                name : "car_id",
                value: "${car_id}",
                allowBlank : false
            } ]
        }, {
            xtype : "container",
            items : [ {
                fieldLabel : "姓名",
                name : "name",
                value: "${name}",
                allowBlank : false
            }, {
                fieldLabel : "性别",
                id : "p00_cust_modify_gender",
                name : "gender",
                xtype : "uXcombo",
                comboOpts : {
                    comboId : crm.consts.CDD_CD0001
                },
                labelWidth : 120,
                width : 280
            } ]
        } ]
    }, {
        title : "服务信息",
        items : [ {
            xtype : "container",
            layout : "vbox",
            items : [ {
                fieldLabel : "会员卡号",
                name : "member_id",
                value: "${member_id}"
            }, {
                fieldLabel : "所属服务点",
                id: "p00_cust_modify_svc_locate_id",
                name : "svc_locate_id",
                xtype : "uXcombo",
                comboOpts : {
                    comboId : crm.consts.CDD_CD0009
                },
                labelWidth : 120,
                width : 280,
                listeners: {
                    change: {
                        fn: function(cbx, newvalue, oldvalue, opts) {
                            p00_cust_modify.autoFillAddr();
                        }
                    }
                }
            }, {
                fieldLabel : "默认车位",
                name : "park_space",
                id: "p00_cust_modify_park_space",
                value: "${park_space}",
                width : 500,
                enableKeyEvents: true,
                listeners: {
                    keyup: {
                        fn: function(text, evt, opts) {
                            p00_cust_modify.autoFillAddr();
                        }
                    }
                }
            } ]
        } ]
    }, {
        title : "汽车信息",
        items : [ {
            xtype : "container",
            layout : "vbox",
            items : [ {
                xtype : "uXcombo",
                fieldLabel : "品牌",
                id: "p00_cust_modify_car_brand",
                name : "car_brand",
                comboOpts : {
                    comboId : crm.consts.CDD_CARBRAND
                },
                labelWidth : 120,
                width : 280
            }, {
                fieldLabel : "颜色",
                name : "car_color",
                id: "p00_cust_modify_car_color",
                xtype : "uXcombo",
                comboOpts : {
                    comboId : crm.consts.CDD_CD0008
                },
                labelWidth : 120,
                width : 280
            }, {
                xtype : "uXcombo",
                name : "car_size_type",
                id: "p00_cust_modify_car_size_type",
                comboOpts : {
                    comboId : crm.consts.CDD_CD0002
                },
                fieldLabel : "车体类型",
                labelWidth : 120,
                width : 280
            } ]
        } ]
    }, {
        title : "联系方式",
        items : [ {
            xtype : "container",
            layout : "vbox",
            items : [ {
                fieldLabel : "备用电话",
                value: "${phone1}",
                name : "phone1"
            }, {
                fieldLabel : "QQ号码",
                value: "${qq}",
                name : "qq"
            }, {
                fieldLabel : "常用地址",
                id: "p00_cust_modify_addr",
                value: "${addr}",
                width : 500,
                name : "addr"
            }, {
                fieldLabel : "备用地址",
                value: "${addr1}",
                width : 500,
                name : "addr1"
            } ]
        } ]
    }, {
        xtype : "container",
        frame : true,
        layout : "anchor",
        margin : "10 0",
        items : [ {
            xtype : "container",
            defaults : {
                xtype : "button",
                style : "margin-right: 5px; padding: 2px 20px"
            },
            items : [ {
                text : "重置",
                handler : function() {
                    this.up("form").getForm().reset();
                    Ext.getCmp(p00_cust_modify.focusId).focus();
                }
            }, {
                text : "保存",
                handler : function() {
                    this.up("form").getForm().submit({
                        url : "cust/edit.shtm",
                        success : function(form, action) {
                            if (action.result.success == "true") {
                                Ext.Msg.alert("信息提示", "保存成功");
                            } else {
                                Ext.Msg.alert("提示信息", action.result.errorMsgs);
                            }
                        },
                        faliure : function(form, action) {
                            Ext.Msg.alert("提示信息", action.result.errorMsgs);
                        }
                    });
                }
            } ]
        } ]
    } ]
});

//show tab content
p00_cust_modify.items = [ p00_cust_modify.addPanel ];
crm.utils.showTabContent(p00_cust_modify);

crm.utils.initRemoteComboBox("p00_cust_modify_gender", "${gender}");
crm.utils.initRemoteComboBox("p00_cust_modify_svc_locate_id", "${svc_locate_id}");
crm.utils.initRemoteComboBox("p00_cust_modify_car_brand", "${car_brand}");
crm.utils.initRemoteComboBox("p00_cust_modify_car_color", "${car_color}");
crm.utils.initRemoteComboBox("p00_cust_modify_car_size_type", "${car_size_type}");

</script>

